#include ".\gameobject.h"
#include ".\Model.h"

#include <cassert>



int GameObject::m_iNextValidID = 0;

GameObject::GameObject(int id)
{
	SetID(id);
	// Set the model pointer to NULL
	m_Model = NULL;
}

GameObject::~GameObject()
{
	// Delete the Model pointer when the object is destroyed
	if (m_Model != NULL)
	{
		delete m_Model;
		m_Model = NULL;
	}
}

//----------------------------- SetID -----------------------------------------
//
//  this must be called within each constructor to make sure the ID is set
//  correctly. It verifies that the value passed to the method is greater
//  or equal to the next valid ID, before setting the ID and incrementing
//  the next valid ID
//-----------------------------------------------------------------------------
void GameObject::SetID(int val)
{
  //make sure the val is equal to or greater than the next available ID
  assert ( (val >= m_iNextValidID) && "<GameObject::SetID>: invalid ID");

  m_ID = val;
    
  m_iNextValidID = m_ID + 1;
}


